/**
 * Created by sunyxq on 16/3/26.
 */
angular.module('hyt.receiptDaoZhanService',[])

    .factory('ZdListWqFactory',function($resource, $rootScope,ENV,Storage,$ionicLoading,$state){
        var APIUrl =  Storage.get('fwqdz'),
            dzListData = {},dzListDatas={},
            pagesize = 10;

        var resource = $resource(APIUrl);

        return {
            //未签列表
            getZdWqList: function(sid,user_id,yh_id,zd_id,dw_id) {
                var hasNextPage =true;    //判断是否有下一页

                return resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#daozhan_qianshou_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize':pagesize,
                        'current_page':'1',
                        'dw_id':dw_id,
                        'shbm_id' : zd_id,
                        'yh_id':yh_id,
                        'zt':2,
                        'clzt':2,
                        'zd_id':zd_id,
                        'cph':'',
                        'fhrmc':'',
                        'cl_id':'',
                        'fhbm_id':'',
                        'zcsj_ks':'',
                        'zcsj_js':''
                    }

                }, function(r) {
                    if(r.ACTION_RETURN_CODE == "000000"){
                        if(r.ACTION_INFO.RESULT_LIST.length < pagesize){
                            hasNextPage = false;
                        }

                        dzListData[pagesize] = {
                            hasNextPage : hasNextPage,
                            'current_page' : 2,
                            'data' : r.ACTION_INFO.RESULT_LIST
                        };
                        console.log(dzListData[pagesize])

                        $rootScope.$broadcast('zdListWq.zdUpdated');
                    }else if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }
                });
            },

            getWqZd : function(){
                if(dzListData[pagesize] == undefined){
                    return false;
                }
                return dzListData[pagesize];
            },

            getMoreWqCyd:function(sid,user_id,yh_id,zd_id,dw_id){

                //为了解决一步加载的时候数据还没有加载完成  然后请求loadMore的时候  找不到数据
                if(dzListData[pagesize] == undefined){
                    return false;
                }

                //获取以前的数据
                var hasNextPage = dzListData[pagesize].hasNextPage;
                var current_page = dzListData[pagesize].current_page;
                var moreZdListData = dzListData[pagesize].data;

                //console.log(moreCydListData);

                resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#daozhan_qianshou_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize':pagesize,
                        'current_page': current_page,
                        'dw_id':dw_id,
                        'shbm_id' : zd_id,
                        'yh_id':yh_id,
                        'zt':2,
                        'clzt':2,
                        'zd_id':zd_id,
                        'cph':'',
                        'fhrmc':'',
                        'cl_id':'',
                        'fhbm_id':'',
                        'zcsj_ks':'',
                        'zcsj_js':''
                    }
                }, function (r) {

                    current_page++;

                    if(r.ACTION_RETURN_CODE == "000000"){
                        if(r.ACTION_INFO.RESULT_LIST.length < pagesize){
                            hasNextPage = false;
                        }

                        moreZdListData = moreZdListData.concat(r.ACTION_INFO.RESULT_LIST);

                        dzListData[pagesize] = {
                            hasNextPage : hasNextPage,
                            'current_page' : current_page,
                            'data' : moreZdListData
                        };

                        $rootScope.$broadcast('zdListWq.zdUpdated');
                    }else if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }


                })
            },
            hasNextPageWq: function() {
                if (dzListData[pagesize] === undefined) {
                    return false;
                }
                return dzListData[pagesize].hasNextPage;
            },
            //扫码未签列表
            getZdWqLists: function(sid,user_id,yh_id,zd_id,cph,sfz,startDate,endDate,dw_id) {
                var hasNextPage =true;    //判断是否有下一页

                return resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#daozhan_qianshou_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize':pagesize,
                        'current_page':'1',
                        'dw_id':dw_id,
                        'shbm_id' : zd_id,
                        'yh_id':yh_id,
                        'zt':2,
                        'clzt':2,
                        'cph':cph,
                        'fhbmmc':sfz,
                        'zcsj_ks':startDate,
                        'zcsj_js':endDate,
                        'zd_id':zd_id
                    }
                }, function(r) {
                    if(r.ACTION_RETURN_CODE == "000000"){
                        if(r.ACTION_INFO.RESULT_LIST.length < pagesize){
                            hasNextPage = false;
                        }

                        dzListDatas[pagesize] = {
                            hasNextPage : hasNextPage,
                            'current_page' : 2,
                            'data' : r.ACTION_INFO.RESULT_LIST
                        };
                        console.log(dzListDatas[pagesize])

                        $rootScope.$broadcast('zdListWqs.zdUpdated');
                    }else if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }


                });

            },

            getWqZds : function(){
                if(dzListDatas[pagesize] == undefined){
                    return false;
                }
                return dzListDatas[pagesize];
            },

            getMoreWqCyds:function(sid,user_id,yh_id,zd_id,cph,sfz,startDate,endDate,dw_id){

                //为了解决一步加载的时候数据还没有加载完成  然后请求loadMore的时候  找不到数据
                if(dzListDatas[pagesize] == undefined){
                    return false;
                }

                //获取以前的数据
                var hasNextPage = dzListDatas[pagesize].hasNextPage;
                var current_page = dzListDatas[pagesize].current_page;
                var moreZdListData = dzListDatas[pagesize].data;

                //console.log(moreCydListData);

                resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#daozhan_qianshou_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize':pagesize,
                        'current_page': current_page,
                        'dw_id':dw_id,
                        'shbm_id' : zd_id,
                        'yh_id':yh_id,
                        'zt':2,
                        'clzt':2,
                        'cph':cph,
                        'fhbmmc':sfz,
                        'zcsj_ks':startDate,
                        'zcsj_js':endDate,
                        'zd_id':zd_id
                    }
                }, function (r) {

                    current_page++;

                    if(r.ACTION_RETURN_CODE == "000000"){
                        if(r.ACTION_INFO.RESULT_LIST.length < pagesize){
                            hasNextPage = false;
                        }

                        moreZdListData = moreZdListData.concat(r.ACTION_INFO.RESULT_LIST);

                        dzListDatas[pagesize] = {
                            hasNextPage : hasNextPage,
                            'current_page' : current_page,
                            'data' : moreZdListData
                        };

                        $rootScope.$broadcast('zdListWqs.zdUpdated');
                    }else if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }


                })
            },
            hasNextPageWqs: function() {
                if (dzListDatas[pagesize] === undefined) {
                    return false;
                }
                return dzListDatas[pagesize].hasNextPage;
            },
            //到站签收
            getReceipt : function(zcd_id,bm_id,qsrmc,sid,user_id,yh_id,dw_id){
                return resource.save({
                    'ACTION_NAME' : 'sqlKeyBiz.transUpdate#zhandianqianshou_bycheliang',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO' : {
                        'zcd_id' : zcd_id,
                        'yh_id' : yh_id,
                        'bm_id' : bm_id,
                        'qsrmc' : qsrmc,
                        'dw_id' : dw_id
                    }
                },function(r){
                    if(r.ACTION_RETURN_CODE == "000000"&& r.ACTION_INFO.result==1){
                        console.log(r);
                        $rootScope.$broadcast('Receipt.ReceiptUpdate');
                    }else {
                        console.log(r);
                        $rootScope.$broadcast('ErroReceipt.erroReceiptUpdate');
                    }
                });
            }

        };
    })
    .factory('ZdListYqFactory',function($resource, $rootScope,ENV,Storage){
        var APIUrl =  Storage.get('fwqdz'),
            dzListData = {},
            pagesize = 10;

        var resource = $resource(APIUrl);

        return {
            //已签列表
            getZdYqList: function(sid,user_id,yh_id,zd_id,dw_id) {
                var hasNextPage =true;    //判断是否有下一页

                return resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#daozhan_qianshou_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize':pagesize,
                        'current_page':'1',
                        'dw_id':dw_id,
                        'shbm_id' : zd_id,
                        'yh_id':yh_id,
                        'zt':3,
                        'clzt':3,
                        'zd_id':zd_id
                    }
                }, function(r) {
                    if(r.ACTION_RETURN_CODE == "000000"){
                        if(r.ACTION_INFO.RESULT_LIST.length < pagesize){
                            hasNextPage = false;
                        }

                        dzListData[pagesize] = {
                            hasNextPage : hasNextPage,
                            'current_page' : 2,
                            'data' : r.ACTION_INFO.RESULT_LIST
                        };
                        console.log(dzListData[pagesize])

                        $rootScope.$broadcast('zdListYq.zdUpdated');
                    }


                });

            },

            getYqZd : function(){
                if(dzListData[pagesize] == undefined){
                    return false;
                }
                return dzListData[pagesize];
            },

            getMoreYqCyd:function(sid,user_id,yh_id,zd_id,dw_id){

                //为了解决一步加载的时候数据还没有加载完成  然后请求loadMore的时候  找不到数据
                if(dzListData[pagesize] == undefined){
                    return false;
                }

                //获取以前的数据
                var hasNextPage = dzListData[pagesize].hasNextPage;
                var current_page = dzListData[pagesize].current_page;
                var moreZdListData = dzListData[pagesize].data;

                //console.log(moreCydListData);

                resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#daozhan_qianshou_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize':pagesize,
                        'current_page': current_page,
                        'dw_id':dw_id,
                        'shbm_id' : zd_id,
                        'yh_id':yh_id,
                        'zt':3,
                        'clzt':3,
                        'zd_id':zd_id
                    }
                }, function (r) {

                    current_page++;

                    if(r.ACTION_RETURN_CODE == "000000"){
                        if(r.ACTION_INFO.RESULT_LIST.length < pagesize){
                            hasNextPage = false;
                        }

                        moreZdListData = moreZdListData.concat(r.ACTION_INFO.RESULT_LIST);

                        dzListData[pagesize] = {
                            'hasNextPage' : hasNextPage,
                            'current_page' : current_page,
                            'data' : moreZdListData
                        };

                        $rootScope.$broadcast('zdListYq.zdUpdated');
                    }


                })
            },
            hasNextPageYq: function() {
                if (dzListData[pagesize] === undefined) {
                    return false;
                }
                return dzListData[pagesize].hasNextPage;
            }
        };
    })
    .factory('ZdListSearchFactory',function($resource, $rootScope,ENV,Storage,$ionicLoading,$state){
        var APIUrl =  Storage.get('fwqdz'),
            dzListData = {},
            pagesize = 10;

        var resource = $resource(APIUrl);

        return {
            //筛选结果列表
            getZdSearchList: function(sid,user_id,yh_id,zd_id,cph,sfz,startDate,endDate,dw_id) {
                var hasNextPage =true;    //判断是否有下一页

                return resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#daozhan_qianshou_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize':pagesize,
                        'current_page':'1',
                        'dw_id':dw_id,
                        'shbm_id' : zd_id,
                        'yh_id':yh_id,
                        'zt':1,
                        'cph':cph,
                        'fhbmmc':sfz,
                        'zcsj_ks':startDate,
                        'zcsj_js':endDate,
                        'zd_id':zd_id
                    }
                }, function(r) {
                    if(r.ACTION_RETURN_CODE == "000000"){
                        if(r.ACTION_INFO.RESULT_LIST.length < pagesize){
                            hasNextPage = false;
                        }

                        dzListData[pagesize] = {
                            hasNextPage : hasNextPage,
                            'current_page' : 2,
                            'data' : r.ACTION_INFO.RESULT_LIST
                        };
                        console.log(dzListData[pagesize])

                        $rootScope.$broadcast('zdListSearch.zdUpdated');
                    }else if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }


                });

            },

            getSearchZd : function(){
                if(dzListData[pagesize] == undefined){
                    return false;
                }
                return dzListData[pagesize];
            },

            getMoreSearchCyd:function(sid,user_id,yh_id,zd_id,cph,sfz,startDate,endDate,dw_id){

                //为了解决一步加载的时候数据还没有加载完成  然后请求loadMore的时候  找不到数据
                if(dzListData[pagesize] == undefined){
                    return false;
                }

                //获取以前的数据
                var hasNextPage = dzListData[pagesize].hasNextPage;
                var current_page = dzListData[pagesize].current_page;
                var moreZdListData = dzListData[pagesize].data;

                //console.log(moreCydListData);

                resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#daozhan_qianshou_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize':pagesize,
                        'current_page': current_page,
                        'dw_id':dw_id,
                        'shbm_id' : zd_id,
                        'yh_id':yh_id,
                        'zt':1,
                        'cph':cph,
                        'fhbmmc':sfz,
                        'djsj_ks':startDate,
                        'djsj_js':endDate,
                        'zd_id':zd_id
                    }
                }, function (r) {

                    current_page++;

                    if(r.ACTION_RETURN_CODE == "000000"){
                        if(r.ACTION_INFO.RESULT_LIST.length < pagesize){
                            hasNextPage = false;
                        }

                        moreZdListData = moreZdListData.concat(r.ACTION_INFO.RESULT_LIST);

                        dzListData[pagesize] = {
                            hasNextPage : hasNextPage,
                            'current_page' : current_page,
                            'data' : moreZdListData
                        };

                        $rootScope.$broadcast('zdListSearch.zdUpdated');
                    }else if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }


                })
            },

            hasNextPageSearch: function() {
                if (dzListData[pagesize] === undefined) {
                    return false;
                }
                return dzListData[pagesize].hasNextPage;
            },

            //到站签收
            getReceipt : function(zcd_id,bm_id,qsrmc,sid,user_id,yh_id,dw_id){
                return resource.save({
                    'ACTION_NAME' : 'sqlKeyBiz.transUpdate#zhandianqianshou_bycheliang',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO' : {
                        'zcd_id' : zcd_id,
                        'yh_id' : yh_id,
                        'bm_id' : bm_id,
                        'qsrmc' : qsrmc,
                        'dw_id' : dw_id
                    }
                },function(r){
                    if(r.ACTION_RETURN_CODE == "000000"&& r.ACTION_INFO.result==1){
                        $rootScope.$broadcast('Receipt.ReceiptUpdate');
                    }else {
                        $rootScope.$broadcast('ErroReceipt.erroReceiptUpdate');
                    }
                });
            }

        };
    })

    .factory('ZdDetailFactory',function($resource,$rootScope,ENV,Storage,$ionicLoading,$state) {
        var api =  Storage.get('fwqdz'),
            dzDetailData = {},
            pagesize = 10;

        var resource = $resource(api);

        return {

            getZdDetail: function (id,sid,user_id,yh_id,dw_id,zd_id,cydh) {
                var hasNextPage = true;    //判断是否有下一页
                return resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#yundan_query_daozhan',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize': pagesize,
                        'current_page': '1',
                        'yh_id':yh_id,
                        'dw_id':dw_id,
                        'zcd_id': id,
                        'zd_id':zd_id,
                        'cydh':cydh
                    }
                }, function (r) {
                    console.log(r);
                    if (r.ACTION_RETURN_CODE == "000000") {
                        if (r.ACTION_INFO.RESULT_LIST.length < pagesize) {
                            hasNextPage = false;
                        }

                        dzDetailData[pagesize] = {
                            hasNextPage: hasNextPage,
                            'current_page': 2,
                            'data': r.ACTION_INFO.RESULT_LIST
                        };

                        console.log(dzDetailData[pagesize]);
                        $rootScope.$broadcast('zdDetail.detailUpdated');
                    }else if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }


                });

            },

            getDetail: function () {
                if (dzDetailData[pagesize] == undefined) {
                    return false;
                }
                return dzDetailData[pagesize];
            },

            getMoreDetail: function (id,sid,user_id,yh_id,dw_id,zd_id,cydh) {

                //为了解决一步加载的时候数据还没有加载完成  然后请求loadMore的时候  找不到数据
                if (dzDetailData[pagesize] == undefined) {
                    return false;
                }

                //获取以前的数据
                var hasNextPage = dzDetailData[pagesize].hasNextPage;
                var current_page = dzDetailData[pagesize].current_page;
                var moreZdDetailData = dzDetailData[pagesize].data;

                //console.log(moreCydListData);

                resource.save({
                    'ACTION_NAME': 'sqlKeyBiz.page#yundan_query_daozhan',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO': {
                        'pagesize': pagesize,
                        'current_page': current_page,
                        'yh_id':yh_id,
                        'dw_id':dw_id,
                        'zcd_id': id,
                        'zd_id':zd_id,
                        'cydh':cydh
                    }
                }, function (r) {

                    console.log(r);

                    current_page++;

                    if (r.ACTION_RETURN_CODE == "000000") {
                        if (r.ACTION_INFO.RESULT_LIST.length < pagesize) {
                            hasNextPage = false;
                        }

                        moreZdDetailData = moreZdDetailData.concat(r.ACTION_INFO.RESULT_LIST);

                        console.log(moreZdDetailData);

                        dzDetailData[pagesize] = {
                            hasNextPage: hasNextPage,
                            'current_page': current_page,
                            'data': moreZdDetailData
                        };

                        $rootScope.$broadcast('zdDetail.detailUpdated');
                    }else if (r.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }


                })
            },

            hasNextPage: function () {
                if (dzDetailData[pagesize] === undefined) {
                    return false;
                }
                return dzDetailData[pagesize].hasNextPage;
            },

            getSingleReceipt : function(sid,yh_id,user_id,dw_id,cyd_id,sdsl,bm_id,zcdmx_id){
                return resource.save({
                    'ACTION_NAME' : 'sqlKeyBiz.transUpdate#zhandianqianshou_byid',
                    'SID':sid,
                    'USER_ID' : user_id,
                    'ACTION_INFO' : {
                        'yh_id' : yh_id,
                        'dw_id' : dw_id,
                        'cyd_id' : cyd_id,
                        'sdsl' : sdsl,
                        'bm_id':bm_id,
                        'zcdmx_id':zcdmx_id
                    }
                },function(r){
                    if(r.ACTION_RETURN_CODE == "000000"&& r.ACTION_INFO.result==1){
                        $rootScope.$broadcast('SingleReceipt.singleUpdate');
                    }else {
                        $rootScope.$broadcast('ErroSingleReceipt.erroSingleUpdate');
                    }
                });
            }
        }
    })

    .factory('CarFactory',function($resource,ENV,$rootScope,Storage){
        var api =  Storage.get('fwqdz'),
            cphList;

        var resource = $resource(api);

        return{
            getCphList : function(sid,user_id,yh_id,dw_id,zd_id){
                return resource.save({
                    'ACTION_NAME' : 'sqlKeyBiz.list#cph_list_query',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO' : {
                        'yh_id' : yh_id,
                        'dw_id':dw_id,
                        'bm_id':zd_id
                    }
                },function(r){
                    cphList=r;
                    console.log(cphList);
                    $rootScope.$broadcast('List.cphList');
                })
            },
            getCph:function(){
                return cphList;
            }
        }
    })
    .factory('SfzFactory',function($resource,ENV,$rootScope,Storage){
        var api =  Storage.get('fwqdz'),
            sfzList;

        var resource = $resource(api);

        return{
            getSfzList : function(sid,user_id,yh_id,dw_id,zd_id){
                return resource.save({
                    'ACTION_NAME' : 'sqlKeyBiz.list#zhandian_list',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO' : {
                        'yh_id' : yh_id,
                        'zd_id':zd_id,
                        'dw_id':dw_id
                    }
                },function(r){
                    sfzList=r;
                    $rootScope.$broadcast('List.sfzList');
                })
            },
            getSfz:function(){
                return sfzList;
            }
        }
    })
    .factory('HsdjFactory',function($resource,ENV,$rootScope,Storage){
        var api =  Storage.get('fwqdz'),
            result,hsdjDetail;

        var resource = $resource(api);

        return{
            getDetailHsdj : function(sid,user_id,yh_id,cyd_id){
                return resource.save({
                    'ACTION_NAME' : 'printBiz.hsdjSearch',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO' : {
                        'cyd_id':cyd_id,
                        'yh_id' : yh_id
                    }
                },function(r){
                    hsdjDetail= r.ACTION_INFO;
                    console.log(hsdjDetail);
                    $rootScope.$broadcast('Hsdj.detail');
                })
            },
            getDetail:function(){
                return hsdjDetail;
            },
            getHsdj : function(sid,user_id,yh_id,dw_id,cyd_id,zsxm,hsdj,happenDate,bm_id){
                return resource.save({
                    'ACTION_NAME' : 'printBiz.hsdjInsert',
                    'SID':sid,
                    'USER_ID':user_id,
                    'ACTION_INFO' : {
                        'cyd_id':cyd_id,
                        'yh_id' : yh_id,
                        'dw_id':dw_id,
                        'zsxm':zsxm,
                        'hsbz':hsdj.bz,
                        'lrsj':happenDate,
                        'shsl':hsdj.shsl,
                        'dssl':hsdj.dssl,
                        'hs_id':hsdj.hs_id,
                        'bm_id':bm_id,
                        'cydh':hsdj.cydh,
                        'hsbh':hsdj.hsbh,
                        'hw_id':hsdj.hw_id,
                        'hwbh':hsdj.hwbh
                    }
                },function(r){
                    result= r.ACTION_RETURN_CODE;
                    $rootScope.$broadcast('Hsdj.hsdj');
                })
            },
            getResult:function(){
                return result;
            }
        }
    });